# 导包
from time import sleep
from selenium import webdriver
from selenium.webdriver.common.by import By

# 实例化浏览器对象
driver = webdriver.Chrome()
# 打开网址url
driver.get('https://www.baidu.com/')
# 需求
driver.find_element(By.LINK_TEXT, '新闻').click()

handles = driver.window_handles
driver.switch_to.window(handles[-1])

driver.get_screenshot_as_file('D:/萌萌哒的小可爱/info.png')
# 观察效果
sleep(3)
# 关闭网页
driver.quit()

